home *** CD-ROM | disk | FTP | other *** search
- unit uGlobals;
-
- interface
-
- uses Windows, Forms, classes, extctrls, graphics, jpeg, sysutils;
-
- type
- TSSMode = (ssSetPwd,ssPreview,ssConfig,ssRun);
-
- TSSFileImageLocations = class(TComponent)
- private
- ListItems : TStringList;
- function GetCommaList: string;
- function GetItems(index: integer): Integer;
- procedure SetCommaList(const Value: string);
- procedure SetItems(index: integer; const Value: Integer);
- function GetCount: integer;
- public
- constructor Create(AOwner : TComponent); override;
- destructor Destroy; override;
- property Items[index : integer] : Integer read GetItems write SetItems;
- property Count : integer read GetCount;
- function Add(Loc : integer) : integer;
- published
- property CommaList : string read GetCommaList write SetCommaList;
- end;
-
- TSSImage = class(TComponent)
- private
- FFilename: string;
- FPicture: TPicture;
- procedure SetPicture(const Value: TPicture);
- public
- constructor Create(AOwner : TComponent); override;
- destructor Destroy; override;
- procedure Execute(ToPicture : TPicture); virtual;
- published
- property Picture : TPicture read FPicture write SetPicture;
- property Filename : string read FFilename write FFilename;
- end;
-
- TSSTextImage = class(TSSImage)
- private
- FText: String;
- public
- procedure Execute(ToPicture : TPicture); override;
- published
- property Text : String read FText write FText;
- end;
-
- const
- SSMode : TSSMode = ssRun;
-
- procedure ReadIniFile;
- procedure WriteIniFile;
-
- var
- Interval : Integer;
- Section : string;
-
- implementation
-
- uses
- IniFiles;
-
- procedure ReadIniFile;
- var
- IniFile : TIniFile;
- begin
- IniFile := TIniFile.Create('CONTROL.INI');
- Interval := IniFile.ReadInteger(Section,'Interval',5000);
- IniFile.Free;
- end;
-
- procedure WriteIniFile;
- var
- IniFile : TIniFile;
- begin
- IniFile := TIniFile.Create('CONTROL.INI');
- IniFile.WriteInteger(Section,'Interval',Interval);
- IniFile.Free;
- end;
-
- { TSSImage }
-
- constructor TSSImage.Create(AOwner: TComponent);
- begin
- inherited;
- FPicture := TPicture.Create;
- end;
-
-
- destructor TSSImage.Destroy;
- begin
- FPicture.Free;
- inherited;
- end;
-
- procedure TSSImage.Execute(ToPicture : TPicture);
- begin
- ToPicture.Assign(FPicture);
- end;
-
- procedure TSSImage.SetPicture(const Value: TPicture);
- begin
- FPicture.Assign(Value);
- end;
-
- { TSSTextImage }
-
- procedure TSSTextImage.Execute(ToPicture: TPicture);
- var
- tmpBitmap : TBitmap;
- x, y : integer;
- s : TSize;
- begin
- inherited Execute(ToPicture);
- tmpBitmap := TBitmap.Create;
- try
- tmpBitmap.Width := ToPicture.Width;
- tmpBitmap.Height := ToPicture.Height;
- tmpBitmap.Canvas.Draw(0,0,ToPicture.Graphic);
-
- tmpBitmap.Canvas.Brush.Style := bsClear;
- tmpBitmap.Canvas.Font.Size := 32;
- tmpBitmap.Canvas.Font.Color := clWHite;
- tmpBitmap.Canvas.Font.Name := 'Arial';
- s := tmpBitmap.Canvas.TextExtent(FText);
-
- x := ( ToPicture.Width div 2) - (s.cx div 2);
- y := ( ToPicture.Height div 2) - (s.cy div 2);
- tmpBitmap.Canvas.TextOut(x,y,FText);
-
- ToPicture.Bitmap.Assign(tmpBitmap);
- finally
- tmpBitmap.Free;
- end;
- end;
-
- { TSSFileImageLocations }
-
- constructor TSSFileImageLocations.Create(AOwner: TComponent);
- begin
- inherited;
- ListItems := TStringList.Create;
- end;
-
- destructor TSSFileImageLocations.Destroy;
- begin
- ListItems.Free;
- inherited;
- end;
-
- function TSSFileImageLocations.GetCommaList: string;
- begin
- Result := ListItems.CommaText;
- end;
-
- procedure TSSFileImageLocations.SetCommaList(const Value: string);
- begin
- ListItems.CommaText := Value;
- end;
-
- function TSSFileImageLocations.GetItems(index: integer): Integer;
- begin
- if (index > ListItems.Count-1) or (index < 0) then raise Exception.Create('Index is out of bounds');
- result := StrToIntDef(ListItems[index],0);
- end;
-
- procedure TSSFileImageLocations.SetItems(index: integer;
- const Value: Integer);
- begin
- if (index > ListItems.Count-1) or (index < 0) then raise Exception.Create('Index is out of bounds');
- ListItems[index] := IntToStr(Value);
- end;
-
- function TSSFileImageLocations.Add(Loc: integer): integer;
- begin
- result := ListItems.Add(IntToStr(Loc));
- end;
-
- function TSSFileImageLocations.GetCount: integer;
- begin
- result := ListItems.Count;
- end;
-
- initialization
- classes.RegisterClass(TSSFileImageLocations);
- classes.RegisterClass(TSSImage);
- classes.RegisterClass(TSSTextImage);
- Section := 'Screen Saver.'+ExtractFileName(Application.ExeName)+' Screen Saver';
- end.
-
-